package com.usian.controller;

import com.usian.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Value("${server.port}")
    private String port;

    @GetMapping("getUserById/{id}")
    public User getUserById(@PathVariable Integer id){
        User user = new User();
        if (id==1){
            user.setName("张三");
            user.setAge(18);
        }else {
            user.setName("张三疯");
            user.setAge(500);
        }
        System.out.println(port);
        if (id == 1) {
            int i = 1 / 0;
        }
        return user;
    }

    @RequestMapping("addUser")
    public int addUser(@RequestBody User user){
        if (user.getId() != 0 ){
            return 1;
        }
        return 0;
    }

    @RequestMapping("delUser")
    int delUser(@RequestParam Integer id){
        if (id==1){
            return 1;
        }
        return 0;
    }
}
